package com.example.chapter11;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


/**
 * 11.2.1.lambda表达式
 */
public class Demo01 {

    public static void main(String[] args) {
        List list=new ArrayList(Arrays.asList(new String[]{"1", "2", "3"}));
        list.forEach(n -> System.out.println(n));
        list.forEach(System.out::println);  // 使用方法引用

        List<String> list1=new ArrayList<>(Arrays.asList(new String[]{"1", "2", "3"}));
        list1.forEach((String s) -> System.out.println("*" + s + "*"));


        List<Integer> primes = Arrays.asList(new Integer[]{2, 3,5,7});
        int factor = 2;
        primes.forEach(element -> { System.out.println(factor*element); });
    }
}
